Many computer graphic images are created by mathematically modeling the interaction of light with a three dimensional scene from a given viewpoint. This process, called “rendering,” generates a two-dimensional image of the scene from the given viewpoint, and is analogous to taking a photograph of a real-world scene.
As the demand for computer graphics, and in particular for real-time computer graphics, has increased, computer systems with graphics processing subsystems adapted to accelerate the rendering process have become widespread. In these computer systems, the rendering process is divided between a computer's general purpose central processing unit (CPU) and the graphics processing subsystem, architecturally centered about a graphics processing unit (GPU). Typically, the CPU performs high-level operations, such as determining the position, motion, and collision of objects in a given scene. From these high level operations, the CPU generates a set of rendering commands and data defining the desired rendered image or images. For example, rendering commands and data can define scene geometry, lighting, shading, texturing, motion, and/or camera parameters for a scene. The graphics processing subsystem creates one or more rendered images from the set of rendering commands and data. Alternatively, and becoming less prevalent, the CPU can carry out its own rendering, as is the case in many production renderers.
Scene geometry is typically represented by geometric primitives, such as points, lines, polygons (for example, triangles and quadrilaterals), volumes and curved surfaces, defined by one or more two- or three-dimensional vertices. These primitives have material properties that indicate how they interact with light and how they ultimately appear in an image. Material properties include: the color of surfaces, their reflection or refraction properties, light emission of surfaces, scattering and absorption properties of volumes, and even additional geometric properties of surfaces, such as cut-outs, displacements, or bump maps, which are often not modeled in the primary geometric description.
Computer systems often use programming languages and procedural descriptions of material properties to provide the most flexibility in implementing complicated lighting and shading algorithms. The languages used can be general purpose languages, such as C or C++, or domain specific languages commonly referred to as shading languages. To exploit this programmability, applications often define materials with a full procedural description of lighting and shading effects and how they are computed from material parameters, incoming light and other variables. Additionally, applications can include one or more graphics processing subsystem programs, which are executed by the CPU or by the graphics processing subsystem in parallel with a main program executed by the CPU. Although not confined merely to implementing shading and lighting algorithms, these graphics processing subsystem programs are often referred to as “shading programs,” “programmable shaders,” or simply “shaders.”